import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static String getResult(String[] spInput) {
		String result = "";
		int k = Integer.parseInt(spInput[0]);
		String tmpASCII;
		int n, p;
		
		for(int i = 1; i < spInput.length; i++) {
			tmpASCII = Character.toString((char)(Integer.parseInt(spInput[i]) - k));
			p = Integer.parseInt(tmpASCII);
			n = 10 - p;
			
			if(n == 10) {
				result += "0";
			} else {
				result += n;
			}
		}
		
		return (result + "\n");
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output;
		String input;
		String[] spInput;
		
		while((input = br.readLine()) != null) {
			spInput = input.split(" ");
			
			output = new StringBuilder();
			
			output.append(getResult(spInput));
			
			System.out.print(output);
		}
	}
}